<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" id="customerForm">
    <input name="id" id="id" type="hidden"/>
    <input name="productImg" id="productImg" type="hidden"/>
    <br/>
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">考场名称</label>
        <div class="layui-input-inline">
            <input type="text" name="examineeHallName" id="examineeHallName" autocomplete="off" lay-verify="required"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">考场地址</label>
        <div class="layui-input-inline">
            <input type="text" name="examineeHallAddress" id="examineeHallAddress" autocomplete="off"
                   lay-verify="required"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 10%">
        <label class="layui-form-label" style="width: 120px">座位数</label>
        <div class="layui-input-inline">
            <input type="text" name="seatCount" id="seatCount" autocomplete="off" lay-verify="required"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 10%" id="timeDiv">
        <label class="layui-form-label" style="width: 120px">创建时间</label>
        <div class="layui-input-inline">
            <input type="text" name="createTime" id="createTime" autocomplete="off" required
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 10%" id="recordDiv">
        <label class="layui-form-label" style="width: 120px">考试安排记录</label>
        <div class="layui-input-inline" style="width: 80%">
            <table class="layui-table" id="grid" lay-filter="grid">
            </table>
        </div>
    </div>
    <button class="layui-btn" id="formSubmit" lay-submit="" lay-filter="formSubmit" style="display: none">立即提交
    </button>
</form>
<script th:replace="/common/inc::incJs"></script>
<style type="text/css">
    .w-e-text-container {
        height: 500px !important;
        width: 700px /*!important是重点，因为原div是行内样式设置的高度300px*/
    }

    .layui-table-header {
        width: 886px;
    }
</style>
<script>
    var form = layui.form;
    var successCallback;
    var id = getQueryString("id");
    $("#id").val(id);

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#createTime', //指定元素
            type: 'datetime'
        });
    });

    //监听提交
    form.on('submit(formSubmit)', function (data) {
        if (id != "") {
            $.post('/backend/security/examineeHall/updateExamineeHall', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                } else {
                    layer.msg('操作成功');
                    successCallback && successCallback();
                }
            });
        } else {
            $.post('/backend/security/examineeHall/addExamineeHall', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                } else {
                    layer.msg('操作成功');
                    successCallback && successCallback();
                }
            });
        }
        return false;
    });

    var formSubmit = function (callback) {
        successCallback = callback;
        $("#formSubmit").click();
    }

    //初始化加载
    $(function () {
        if (id != "") {
            $.post('/backend/security/examineeHall/getById', {id: id}, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                } else {
                    $("form").loadData(res.body);
                    layui.form.render('select');
                }
            });

            var tableIns = createTable({
                url: '/backend/security/examineeArrange/examineeList?id=' + id,
                cols: [[{field: 'examineeSubject', title: '考试名称', width: 180},
                    {field: 'examineeStartTime', title: '开始时间', width: 200}, {
                        field: 'examineeEndTime',
                        title: '结束时间',
                        width: 200
                    }, {
                        field: 'examineeNo',
                        title: '考试人数',
                        width: 120
                    }, {
                        field: 'isPay',
                        title: '缴费文件是否上传',
                        width: 180,
                        templet: '#payTpl'
                    }
                ]]
            });
        } else {
            $("#timeDiv").hide();
            $("#recordDiv").hide();
        }
    })
</script>
<script type="text/html" id="payTpl">
    {{#  if(d.isPay ===1){ }}
    <span style="color: green;">已缴费</span>
    {{#  } else { }}
    <span style="color: #FF0000;">未缴费</span>
    {{#  } }}
</script>
</body>
</html>
